package com.dbappsecurity.network.api;

import com.dbappsecurity.network.Api;

/**
 * Created by Arirus on 2018/5/17.
 */

public abstract class OnResponseResult<T> implements Api.onResponseObject<Object> {
    abstract public void getResult(int code, T data, String message);

    T data;

    final Class<T> typeParameterClass;

    public OnResponseResult(Class<T> typeParameterClass) {
        this.typeParameterClass = typeParameterClass;
    }


    @Override
    public void accept(Object o) throws Exception {

    }

//  @Override
//  public void call(Result result) {
//    Log.i(ARIRUS, "call: " + result.code + " " + result.message);
//
//    if (result.data instanceof String) {
//      getResult(result.code, null, result.message);
//    } else {
//      JsonObject jsonObject = GsonUtil.getGson().toJsonTree(result.data).getAsJsonObject();
//      data = GsonUtil.getGson().fromJson(jsonObject, typeParameterClass);
//      getResult(result.code, data, result.message);
//    }
//  }
}
